<template>
  <div id="app">
    <!-- 路由视图 -->
    <router-view />
    
    <!-- 全局加载状态 -->
    <el-loading 
      v-model:visible="globalLoading" 
      :fullscreen="true"
      text="加载中..."
    />
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { useAuthStore } from '@/stores/auth'

const authStore = useAuthStore()

// 全局加载状态
const globalLoading = computed(() => authStore.isLoading)
</script>

<style>
/* 主题CSS变量 */
:root {
  /* 基础主题变量 */
  --primary-color: #409EFF;
  --border-radius: 8px;
  --font-size: 16px;
  
  /* 颜色变量 */
  --bg-color: #f5f5f5;
  --text-color: #333;
  --border-color: #e6e6e6;
  --card-bg: #ffffff;
  --shadow-color: rgba(0, 0, 0, 0.1);
  
  /* 滚动条颜色 */
  --scrollbar-track: #f1f1f1;
  --scrollbar-thumb: #c1c1c1;
  --scrollbar-thumb-hover: #a8a8a8;
}

/* 深色模式变量 */
[data-theme="dark"] {
  --primary-color: #409EFF;
  --border-radius: 8px;
  --font-size: 16px;
  
  /* 颜色变量 */
  --bg-color: #121212;
  --text-color: #e0e0e0;
  --border-color: #333;
  --card-bg: #1a1a1a;
  --shadow-color: rgba(0, 0, 0, 0.3);
  
  /* 滚动条颜色 */
  --scrollbar-track: #2a2a2a;
  --scrollbar-thumb: #555;
  --scrollbar-thumb-hover: #777;
}

/* 全局样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  height: 100%;
  font-size: var(--font-size);
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Element Plus 全局样式覆盖 */
.el-card {
  border-radius: var(--border-radius);
  border: none;
  box-shadow: 0 2px 12px var(--shadow-color);
  background-color: var(--card-bg);
}

.el-button {
  border-radius: var(--border-radius);
  font-weight: 500;
  transition: all 0.3s ease;
}

.el-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.el-input__wrapper {
  border-radius: var(--border-radius);
  transition: all 0.3s ease;
}

.el-input__wrapper:hover {
  box-shadow: 0 0 0 1px var(--el-color-primary) inset;
}

.el-form-item__error {
  font-size: 12px;
  padding-top: 4px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  #app {
    font-size: 14px;
  }
  
  .el-card {
    border-radius: 8px;
  }
  
  .el-button {
    padding: 8px 16px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  #app {
    font-size: 13px;
  }
  
  .el-card {
    border-radius: 6px;
  }
  
  .el-button {
    padding: 6px 12px;
    font-size: 13px;
  }
}

/* 深色模式支持 - 保留作为后备 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --border-color: #333;
    --card-bg: #1a1a1a;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --scrollbar-track: #2a2a2a;
    --scrollbar-thumb: #555;
    --scrollbar-thumb-hover: #777;
  }
}

/* 动画效果 */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

.slide-up-enter-active,
.slide-up-leave-active {
  transition: all 0.3s ease;
}

.slide-up-enter-from {
  opacity: 0;
  transform: translateY(30px);
}

.slide-up-leave-to {
  opacity: 0;
  transform: translateY(-30px);
}

/* 工具类 */
.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 3rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 3rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 3rem; }

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-column {
  flex-direction: column;
}

.w-full {
  width: 100%;
}

.h-full {
  height: 100%;
}

.hidden {
  display: none;
}

@media (max-width: 768px) {
  .mobile-hidden {
    display: none;
  }
}
</style>
